﻿using Center.lib.utils.log;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebSocketSharp;

namespace ahdelivery.pdd.ws
{
    public class WsUtils
    {
        private WebSocket webSocket = null;

        public void connect(string ip, int port)
        {
            String url = String.Format("ws://{0}:{1}", ip, port);
            webSocket = new WebSocket(url);
            webSocket.OnMessage += onMessage;
            webSocket.Connect();
        }
        public void sendData(String data)
        {
            if (webSocket != null)
            {
                webSocket.Send(data);
            }
        }
        private void onMessage(object sender, MessageEventArgs e)
        {
            LogHelper.WriteLog(e.Data);
        }
    }
}
